<template>
	<view class="root-box root-container root-page-top">
		<view class="content">
			<view class="form-box">
				<view class="flx-default">
					<view class="mt-8"><tui-icon custom-prefix="lishitong" name="lishitong-wenjian_pdf" size="24" color="#333"></tui-icon></view>
					<view class="pl-20 fz32 cgray" >考核成绩单上传</view>
				</view>
				<UploadButton 
				       boxPadding="20rpx 0"
				      :buttonStyle="{ backgroundColor: '#f8875d', color: '#fff', borderRadius: '20rpx', padding: '20rpx',fontSize:'32rpx' }"
				      imgSize="40rpx"
				      :fileNameStyle="{ color: '#333', fontSize: '26rpx' }"
				      text="选择成绩单文件"
				      @success="handleUploadSuccess"
				      @fail="handleUploadFail"
				/>
				
				<view class="flx-default">
					<view class="mt-8"><tui-icon custom-prefix="lishitong" name="lishitong-dingwei" size="24" color="#333"></tui-icon></view>
					<view class="pl-20 fz32 cgray" >申请区域选择</view>
				</view>
				
				<view class="area-box mt-20" @click.stop="openArea">
					<view class="fz30">{{selfArea}}</view>
					<view class="select-box">请选择</view>
				</view>
				
				<view class="flx-default mt-20">
					<view class="mt-8"><tui-icon custom-prefix="lishitong" name="lishitong-fanhuima" size="24" color="#333"></tui-icon></view>
					<view class="pl-20 fz32 cgray" >附加说明（可选）</view>
				</view>
				
				<view class="textarea-box">
					<uv-textarea v-model="model.additional_notes" placeholder="请简要说明你的申请理由或特殊情况..."
					border="none" :customStyle="{backgroundColor:'#efefef',marginTop:'20rpx'}" :maxlength="500"></uv-textarea>
				</view>
			</view>
			<view class="mt-30">
			<uv-button type="primary" text="提交资料" customStyle="margin-top: 10px" @click="submit" color="red"></uv-button>
			</view>
			<view class="bottom-box mt-20">
				<view class="flx-default fz20 cgray">
					<view>
						<uv-checkbox-group v-model="checkboxValue" >
						<uv-checkbox activeColor="red"></uv-checkbox>
						</uv-checkbox-group>
					</view>
					<view > 我已阅读并同意</view> <view class="cred">《联创合伙人协议》</view>
				</view>
				
			</view>
		</view>
		

	</view>
</template>

<script setup>
	
	import { ref, reactive, nextTick,computed,onMounted, onUnmounted} from 'vue';
	
	
	
	import {
		onLoad,
		onReady,
		onShow,
		onBackPress
	} from '@dcloudio/uni-app'
	
	

	import {
		storeToRefs
	} from 'pinia'

	import {
		useUserStore
	} from '@/store'
	import {
		applyVenturePartnerAdd

	} from '@/api/other.js'
	
	import UploadButton from '@/components/UploadButton.vue'


	import {
		navigate,checkEmptyProperties
	} from '@/util/tools.js';
	const user = useUserStore()
	const {
		token,
		userInfo
	} = storeToRefs(user)
    const model = reactive({
		additional_notes:'',
		image:''
	})
	const selfArea=ref('请选择申请区域')
	const checkboxValue=ref(false)
	
	
	onMounted(() => {
	  // 监听事件
	  uni.$on('refreshAreaSelect', (data) => {
	    Object.assign(model,data)
		selfArea.value = data.select
	  })
	})
	
	onUnmounted(() => {
	  // 页面卸载时取消监听，避免内存泄漏
	  uni.$off('refreshAreaSelect')
	})
	
	
	
	
    const openArea=()=>{
		
		let url='/pages-public/SelectCityArea/SelectCityArea?select_level=4'
		navigate(url)
	}
	const handleUploadSuccess = (res) => {
	    model.image=res.url
	}
	
	const handleUploadFail = (err) => {
	  console.error('上传失败:', err)
	}

	const submit = () => {
		
		console.log('---checkboxValue.value',checkboxValue.value)
		if(!checkboxValue.value || checkboxValue.value.length==0){
			uni.$uv.toast('请同意联创合伙人协议')
			return false;
		}
		if(checkEmptyProperties(model)){
			uni.$uv.toast('提交参数不完整')
			return false;
		}
		const res = applyVenturePartnerAdd(model)
		if (res.code === 200) {
			uni.$uv.toast('信息提交成功')
		}
		
		
	}
</script>

<style>
	page {
		background-color: #F6F4F7;
	}
</style>

<style lang="scss">
	.root-box {


		.content {
			padding: 10rpx 20rpx;
			box-sizing: border-box;
		}
	}

	.form-box {
		
		border-radius: 20upx;
		background-color: #fff;
		padding: 30upx 30upx;
		box-sizing: border-box;
	}
	
	.bottom-box{
		display: flex;
		align-items: center;
		justify-content: center;
		
	}
	
	.area-box{
		box-sizing: border-box;
		display:flex;
		justify-content: space-between;
		align-items: center;
		background-color: #efefef;
		border-radius: 10upx;
		padding: 20upx 30upx;
	}
	.select-box{
		padding: 5upx 30upx;
		border-radius: 50upx;
		background-color: red;
		font-size: 24upx;
		color: #fff;
		flex-shrink: 0;
		white-space: nowrap;
			
	}
	
	.citySelect {
		height: calc(100vh - var(--window-top));
		box-sizing: border-box;
		font-size: 28upx;
	}
</style>